package com.itheima.controller;

import com.itheima.domain.VolunteerInfo;
import com.itheima.domain.VolunteerInfoVo;
import com.itheima.service.VolunteerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 12441
 * @Date 2022/9/20 9:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/volunteer")
public class VolunteerController {
    @Autowired
    VolunteerInfoService volunteerInfoService;
    @GetMapping("{id}")
    public VolunteerInfo getVolunteerById(@PathVariable long id){
        return volunteerInfoService.getVolunteerById(id);
    }
    @PutMapping
    public void addVolunteer(@RequestBody VolunteerInfo volunteerInfo){
        volunteerInfoService.addVolunteer(volunteerInfo);
    }
    @DeleteMapping("{id}")
    public void deleteVolunteerById(@PathVariable long id){
        volunteerInfoService.deleteVolunteer(id);
    }
    @PostMapping
    public void updateVolunteer(@RequestBody VolunteerInfoVo vo){
        volunteerInfoService.updateVolunteer(vo);
    }
}
